home *** CD-ROM | disk | FTP | other *** search
- TITLE CAPTURE Version 3.0 - REDIRECT LPT1 TO DISK
- PAGE 64,132
-
- ; 4/03/84 - requires DOS 2.0 or above
- COMMENT |
-
- CAPTURE filespec
-
- Captures all printer output to memory buffer until the buffer
- is full or a '^Z' is received. The contents of the buffer is
- then written to filespec and a system reset is performed. I
- use this to copy debug output to disk for later perusal and
- editing. i.e. dis-assemblies of .com files
-
- Please note that the reason for the system reset is that I have
- not found any other way to keep from hanging the system after
- the file is written. If anyone knows how please let me hear
- about it. CAPTURE does not support path names.
-
- Note that to generate a ^Z type the F6 key or control Z while in
- DOS. CAPTURE actually watches for the string '^Z' to terminate, not
- 1AH as would normally be expected. The size of the memory buffer
- can be changed by changing the BUFSIZ equate to whatever you wish
- and then reassembling, linking and converting to a '.COM' file with
- EXE2BIN.
-
- Ted Reuss c/o South Texas Software, Inc.
- 5847 San Felipe, Suite 1800
- Houston, TX 77057
- (713) 783-9321
- |
-
- BUFSIZ EQU 8000H ; buffer size (32768)
- CR EQU 0DH ; carriage return
- LF EQU 0AH ; linefeed
- EOF EQU 1AH ; DOS end of file
- UFCB1 EQU DS:005CH ; DOS file control blk
-
- @STROUT EQU 9H ; print string
- @CLOSF EQU 10H ; close file
- @CRTEF EQU 16H ; create file
- @SETDTA EQU 1AH ; set disk transfer addr
- @WRRND EQU 22H ; random write
- @SETRND EQU 24H ; set random record field
- @SETINT EQU 25H ; set interrupt vector
- @WRBLK EQU 28H ; random block write
- @GETCIF EQU 34H ; get CIF pointer
- @GETINT EQU 35H ; get interrupt vector
-
- ; A MACRO to call DOS via interrupt 21H. Function codes are
- ; passed in AH. DL/DX are set, if passed, according to the
- ; function number/type.
-
- DOSCALL MACRO FUNC,PARM1
- f_c = FUNC
- IFNB <PARM1>
- if f_c eq 2 or (f_c ge 4 and f_c le 6) or f_c eq 0EH or f_c eq 2EH
- MOV DL,PARM1
- ELSE
- MOV DX,OFFSET PARM1
- ENDIF
- ENDIF
- MOV AH,FUNC
- INT 21H
- ENDM
-
- ; A MACRO to set an interrupt vector.
- ; SETINT interrupt_number, segment_addr, offset_addr
-
- SETINT MACRO inbr,iseg,iofs
- MOV AX,iseg
- MOV DS,AX
- MOV DX,iofs
- MOV AX,2500H+inbr
- INT 21H
- ENDM
-
- ; Note that an INT 19H should be enough to reboot, but on my system which
- ; uses a Tallgrass 12 meg disk I have to reset the following interrupt
- ; vectors to prevent the system from hanging. When I first figured this
- ; out I did not take the time to elimate each one and therefore I may be
- ; resetting more than neccessary.
-
- REBOOT MACRO
- SETINT 09H,0F000H,0E987H ; Keyboard
- SETINT 0BH,0,0 ; Comm 2, set by TGTBIO
- SETINT 10H,0F000H,0F065H ; Video
- SETINT 16H,0F000H,0E82EH ; Keyboard I/O
- SETINT 1CH,0F000H,0FF53H ; Timer Tick
- INT 19H ; BIOS bootstrap
- ENDM
-
-
- CAPTURE SEGMENT PUBLIC 'CODE'
- ASSUME CS:CAPTURE,DS:CAPTURE,ES:NOTHING
- SEGADDR = $
- ORG 100H ;use EXE2BIN -> .com file
- START: JMP INIT ; go do initialization
-
- XFLAG DB 0 ; set when done
- BUFSEG DW 0 ; segment addr of buffer
- BUFLEN DW BUFSIZ ; buffer length
- BUFPTR DW -1 ; buffer input pointer
- ;
- ; PRINTER INTERRUPT ROUTINE - INT 17
- ;
- INT_17 LABEL NEAR
- STI ;interrupts back on
- OR AH,AH
- JZ L0005 ; If print char call
- L0001: DB 0EAH ; Prefix byte for FAR jump
- O17_IP DW 0 ; IP of original int 17H
- O17_CS DW 0 ; CS of original int 17H
- L0005: CMP CS:XFLAG,1
- JZ L0001 ; If done
- PUSH AX ;save all registers
- PUSH BX
- PUSH CX
- PUSH DX
- PUSH DS
- PUSH ES
- PUSH CS ; establish our data
- POP DS ; segment address
- L0010:
- MOV ES,BUFSEG ; ES <- buffer segment
- INC BUFPTR ; increment buffer pointer
- MOV BX,BUFPTR ; BX <- buffer pointer
- CMP BX,BUFLEN ; buffer full?
- JA L0020 ; yes .. go write it
- MOV ES:[BX],AL ; put character in buffer
- CMP AL,'Z' ; check for ^Z
- JNZ L0030 ; nope
- CMP BYTE PTR ES:[BX-1],'^' ; for sure?
- JNZ L0030 ; nope .. return
- L0020:
- MOV XFLAG,1 ; set done flag
- PUSH DS ; save DS
- PUSH ES ; make
- POP DS ; DS = ES
- XOR DX,DX ; DX = 0
- DOSCALL @SETDTA ; set DTA to DS:0
- POP DS ; restore DS
- DOSCALL @WRRND,UFCB1 ; write buffer
- DOSCALL @CLOSF,UFCB1 ; close file
- REBOOT ; Re-boot System
-
- L0030: POP ES ; restore registers
- POP DS
- POP DX
- POP CX
- POP BX
- POP AX
- MOV AH,0D0H ; set printer status OK
- IRET ; and return to caller
-
- IF ($-SEGADDR) MOD 16 ; check if on segment boundary
- ;
- ORG ($-SEGADDR)+16-(($-SEGADDR) MOD 16)
- ; assure segment boundary
- ENDIF
- BUFFER EQU THIS BYTE
- ;
- SUBTTL INITIALIZATION SECTION
- PAGE
- ;
- ; Note that this section of code
- ; is overlayed by the buffer
- ;
- ERRMSG1 DB 'Invalid filespec.',CR,LF,'$'
- INIT:
- PUSH CS ; establish data
- POP DS ; segment address
- XOR AX,AX ; AX = 0
- PUSH AX ; set up for return to DOS
- DOSCALL @CRTEF,UFCB1 ; create & open file
- INC AL
- JNZ I0010 ; if file opened ok
- DOSCALL @STROUT,ERRMSG1 ; else print error msg
- RET ; return to DOS
- I0010:
- MOV AX,BUFLEN ; AX <- buffer length
- MOV WORD PTR UFCB1+14,AX ; set record length
- DOSCALL @SETRND,UFCB1 ; set random record field
-
- MOV AL,17H
- DOSCALL @GETINT ; Get INT 17H vector
- MOV O17_IP,BX ; and modify ourself
- MOV O17_CS,ES ; with it
- MOV AL,17H
- LEA DX,INT_17
- DOSCALL @SETINT ; Set INT 17H to us
-
- MOV DX,OFFSET BUFFER ; DX = offset of buffer
- MOV CL,4 ; CL = shift count
- SHR DX,CL ; DX = extra segment addr for buffer
- MOV AX,CS ; AX -> current segment
- ADD DX,AX ; add in current CS
- MOV BUFSEG,DX ; save segment addr of buffer
-
- MOV SI,BUFLEN ; SI = offset to buffer
- LEA DX,BUFFER[SI] ; DX = nbr of bytes to reserve
- INT 27H ; return to DOS w/o releasing memory
-
- CAPTURE ENDS
- END START